from redis import StrictRedis
import logging



class Config(object):
    """工程配置信息"""
    DEBUG = True
    SECRET_KEY = "68mCLsfkve+H/E7lCMbDwrgxNpHVtqpSXSpbbhVy9YvKPwrsSAOCcpVwU4oQ922n"

    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis 配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # session 保存配置
    SESSION_TYPE = "redis"
    # 指定session 保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间, 单位s
    PERMANENT_SESSION_LIFETIME = 86400



class DevelopmentConfig(Config):
    """开发环境下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产环境下的配置"""
    LOG_LEVEL = logging.ERROR


class TestingConfig(Config):
    """测试环境下的配置"""
    TESTING = True
    LOG_LEVEL = logging.DEBUG


config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}